package little;


import java.util.Arrays;
import java.util.Scanner;

public class littlec
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in );//ctrl+shift+o
		
		int[] digits=null;
		while(true){
		String choice = sc.nextLine();
		switch (choice) 
		{
		case "fib":
			int n = Integer.parseInt(sc.nextLine());
			fib(n);
			break;
			
		case "sort":
			String line = sc.nextLine();
			String[] strDigits = line.split(" ");
			digits = convertToIntDigits(strDigits);
			Arrays.sort(digits);
			System.out.println(Arrays.toString(digits));
			break;
			
			
		case "search":
			Arrays.sort(digits);
			int digit =Integer.parseInt(sc.nextLine());
			int pos=Arrays.binarySearch(digits, digit);
			if(pos<0)
			{
				System.out.println(-1);
			}
			else
			{
				System.out.println(pos);
			}
			break;
			
			
		case "getBirthDate":
			int x=Integer.parseInt(sc.nextLine());
			for(int i=0;i<x;i++){
				String id=sc.nextLine();
				System.out.println(getBirthDate(id));
				}
			break;
			
			
		/**/default:
			System.out.println("exit");
			break;
			}}

	}

	private static void fib(int n) 
	{int i,k=1,sum=0,j;
	for(i=0;i<n;i++){
		if(i==0||i==1)
			{System.out.print("1 ");
			sum=2;
			}
		else{
			System.out.print(sum+" ");
			j=sum;
			sum+=k;
			k=j;
		}
		}}
	
		
	
	
	
	private static int[] convertToIntDigits(String[] strDigits)
	{	int i;
		int[] digits = new int[strDigits.length];
		for(i=0;i<strDigits.length;i++){
			digits[i]= Integer.parseInt(strDigits[i]);
		}
		return digits;
	}
	
	private static String getBirthDate(String id){
		String year=id.substring(6, 10);
		String month=id.substring(10, 12);
		String day=id.substring(12, 14);
		return year+"-"+month+"-"+day;
	}
/**/}